/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.jm.financeiro.entity;

import br.jm.financeiro.filter.ConfiguraCampoAnnotation;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author joao
 */
@Entity
@Table(name = "cep_endereco", catalog = "salao", schema = "public")
public class CepEndereco implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cep_endereco_cod_logradouro_seq")
    @SequenceGenerator(name = "cep_endereco_cod_logradouro_seq", sequenceName = "cep_endereco_cod_logradouro_seq", initialValue = 1, allocationSize = 1)
    @Column(name = "cod_logradouro")
    @JoinColumn(name = "cod_logradouro",
    referencedColumnName = "cod_logradouro",
    nullable = false, //trocar para true se for possível 0-N
    insertable = true, //trocar para true
    updatable = false)
    private Integer codLogradouro;
    @ConfiguraCampoAnnotation(tipo = "String", pesquisa = "codBairro.dscBairro", campo = "dsc_bairro", nomeTabela = "cep_endereco", nomeTabelJoin = "cep_bairro")
    @Column(name = "dsc_complemento", length = 50)
    private String dscComplemento;
    @Basic(optional = false)
    @Column(name = "dsc_logradouro", nullable = false, length = 50)
    @ConfiguraCampoAnnotation(tipo = "String", pesquisa = "codBairro.codCidade.dscCidade", campo = "dsc_cidade", nomeTabela = "cep_endereco", nomeTabelJoin = "cep_cidade")
    private String dscLogradouro;
    @Basic(optional = false)
    @Column(name = "num_cep", nullable = false, length = 10)
    private String numCep;
    @JoinColumn(name = "cod_bairro", referencedColumnName = "cod_bairro", nullable = false)
    @ManyToOne(optional = false)
    @ConfiguraCampoAnnotation(tipo = "String", pesquisa = "codBairro.codCidade.codUf.codUf", campo = "cod_uf", nomeTabela = "cep_endereco", nomeTabelJoin = "cep_uf")
    private CepBairro codBairro;

    /*
     @OneToMany(cascade = CascadeType.ALL, mappedBy = "codLogradouro")
     private List<ClienteEndereco> clienteEnderecoList;
     @OneToMany(mappedBy = "codLogradouro")
     private List<FornecedorEndereco> fornecedorEnderecoList;
     * 
     */
    public CepEndereco() {
    }

    public CepEndereco(Integer codLogradouro) {
        this.codLogradouro = codLogradouro;
    }

    public CepEndereco(Integer codLogradouro, String dscLogradouro, String numCep) {
        this.codLogradouro = codLogradouro;
        this.dscLogradouro = dscLogradouro;
        this.numCep = numCep;
    }

    public Integer getCodLogradouro() {
        return codLogradouro;
    }

    public void setCodLogradouro(Integer codLogradouro) {
        this.codLogradouro = codLogradouro;
    }

    public String getDscComplemento() {
        return dscComplemento;
    }

    public void setDscComplemento(String dscComplemento) {
        this.dscComplemento = dscComplemento;
    }

    public String getDscLogradouro() {
        return dscLogradouro;
    }

    public void setDscLogradouro(String dscLogradouro) {
        this.dscLogradouro = dscLogradouro;
    }

    public String getNumCep() {
        return numCep;
    }

    public void setNumCep(String numCep) {
        this.numCep = numCep;
    }

    public CepBairro getCodBairro() {
        return codBairro;
    }

    public void setCodBairro(CepBairro codBairro) {
        this.codBairro = codBairro;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codLogradouro != null ? codLogradouro.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CepEndereco)) {
            return false;
        }
        CepEndereco other = (CepEndereco) object;
        if ((this.codLogradouro == null && other.codLogradouro != null) || (this.codLogradouro != null && !this.codLogradouro.equals(other.codLogradouro))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.jm.financeiro.entity.CepEndereco[ codLogradouro=" + codLogradouro + " ]";
    }
    /*
     public List<ClienteEndereco> getClienteEnderecoList() {
     return clienteEnderecoList;
     }

     public void setClienteEnderecoList(List<ClienteEndereco> clienteEnderecoList) {
     this.clienteEnderecoList = clienteEnderecoList;
     }

     public List<FornecedorEndereco> getFornecedorEnderecoList() {
     return fornecedorEnderecoList;
     }

     public void setFornecedorEnderecoList(List<FornecedorEndereco> fornecedorEnderecoList) {
     this.fornecedorEnderecoList = fornecedorEnderecoList;
     }
     * 
     */
}
